window.onload = function () {
    showSend()
}

function showSend() {
    axios.get("/send/order/findBySend",null).then(e =>{
        var info = e.data;
        var str = "";
        for (var i = 0;i < info.length;i++){
            var obj = info[i];
            str += `<tr>
                        <td>${obj.id}</td>
                        <td>${obj.accept}</td>
                        <td>${obj.phone}</td>
                        <td>${obj.totalPrice}</td>
                        <td><a href="javascript:updateStatus(orderId=${obj.id})">结账</a></td>
                    </tr>`
        }
        $("bodyData").innerHTML = str;
    })
}

function updateStatus(orderId) {
    var str = "已完结";
    axios.get("/send/order/updateStatus",{
        params:{
            orderId,
            status:"已完结"
        }
    }).then(e =>{
        if (e.data == "ok"){
            location.href = "/send/send.html"
        }else {
            alert("网不好，结账不了")
        }
    })
}